<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>
		<!-- .breadcrumb -->
	</div>
	<!-- Main content -->
	<div class="page-content">
    	<div class="row">
    	    <div class="page-header">
    			<h1>电商管家子商户</h1>
    		</div>
            <div class="col-xs-12 margin_t margin_b">
				<div class="table-responsive  tab">
					<form action="" id='add'>
						<div class="form-group col-xs-6">
                            <label>子商户名称</label>
                            <input name="merch_name" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $merchant_info['merch_name']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6">
                            <label>简称</label>
                            <input name="merch_short_name" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $merchant_info['merch_short_name']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>地址</label>
                            <input name="address" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $merchant_info['address']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>证件号</label>
                            <input name="license_no" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $merchant_info['license_no']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>联系人</label>
                            <input name="person" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $merchant_info['person']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>手机号</label>
                            <input name="mobile" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $merchant_info['mobile']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>邮箱</label>
                            <input name="email" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $merchant_info['email']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>银行账户</label>
                            <input name="bank_no" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $merchant_info['bank_no']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>银行联行号(当账户为他行时必填)</label>
                            <input name="bank_num" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $merchant_info['bank_num']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>账户名</label>
                            <input name="account_name" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $merchant_info['account_name']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>账户类型</label><br/>
                            <select class="account_type">
                                <option <?php if($merchant_info['account_type'] == 4){echo "selected='selected'";}?> value="4">他行企业账户</option>
                            	<option value="1">中信银行个人账户</option>
                            	<option value="2">中信银行企业账户</option>
                            	<option value="3">他行个人账户</option>
                            </select>
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>子商户性质</label><br/>
                            <select class="person_type">
                                <option value="1">企业法人</option>
                                <option value="2">其他法人</option>
                                <option value="3">个体工商户</option>
                                <option value="4">自然人</option>
                            </select>
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>账户修改处理</label><br/>
                            <select class="flag">
                                <option value="1">绑定</option>
                                <option value="0">解绑</option>
                            </select>
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>子商户证件类型</label><br/>
                            <select class="corp_id">
                                <option value="206">组织机构代码</option>
                                <option value="226">统一社会信用代码</option>
                                <option value="001">个人身份证</option>
                                <option value="004">民办非企业登记证书</option>
                                <option value="005">社会团体法人登记证书</option>
                                <option value="006">事业单位法人登记证</option>
                                <option value="007">营业执照号码</option>
                                <option value="999">其他</option>
                            </select>
                        </div>
                        
                        <div class="form-group" style="margin-top: 24px;margin-left: 14px;float: left"><button id="btnSubmit" class="btn btn-info" type="button">提交</button></div>
					</form>
					
            	</div><!-- /.table-responsive -->
			</div>
			
		</div><!-- /.row -->
	</div><!-- /.page-content -->
	<script type="text/javascript">
        $('#btnSubmit').click(function(){
            var gasstation_id = "<?php echo $gasstation_id?>";
            var dingdang_merch_id = "<?php echo $merchant_info['dingdang_merch_id']?>";
            var merch_name = $('input[name="merch_name"]').val();
            var merch_short_name = $('input[name="merch_short_name"]').val();
            var address = $('input[name="address"]').val();
            var person = $('input[name="person"]').val();
            var mobile = $('input[name="mobile"]').val();
            var email = $('input[name="email"]').val();
            var corp_id = $('.corp_id').val();
            var bank_no = $('input[name="bank_no"]').val();
            var bank_num = $('input[name="bank_num"]').val();
            var license_no = $('input[name="license_no"]').val();
            var person_type = $('.person_type').val();
            var account_name = $('input[name="account_name"]').val();
            var account_type = $('.account_type').val();
            var flag = $('.flag').val();
            
            if(license_no == ''){
                alert('子商户证件号不能为空');
                return;
            }
            if(gasstation_id == '请选择'){
                alert('请选择油站');
                return;
            }
            if(merch_name == ''){
                alert('油站名不能为空');
                return;
            }
            if(address == ''){
                alert('地址不能为空');
                return;
            }
            if(person == ''){
                alert('联系人不能为空');
                return;
            }
            if(mobile == ''){
                alert('手机号不能为空');
                return;
            }
            if(email == ''){
                alert('邮箱不能为空');
                return;
            }
            if(bank_no == ''){
                alert('银行账户不能为空');
                return;
            }
            if(account_name == ''){
                alert('账户名不能为空');
                return;
            }
            if(account_type == 0){
                alert('请选择账户类型');
                return;
            }
            if(bank_num == '' && account_type > 2){
                alert('银联号不能为空');
                return;
            }
            $('#btnSubmit').text('请稍后...');

            $.post('<?php echo base_url()."/admin/systems/edit_merchant"?>',{
                gasstation_id:gasstation_id,
                dingdang_merch_id:dingdang_merch_id,
                merch_short_name:merch_short_name,
                merch_name:merch_name,
                license_no:license_no,
                person_type:person_type,
                address:address,
                person:person,
                corp_id:corp_id,
                mobile:mobile,
                email:email,
                bank_no:bank_no,
                account_name:account_name,
                account_type:account_type,
                bank_num:bank_num,
                flag:flag
            },function(res){
                $('#btnSubmit').text('提交');
                var data = JSON.parse(res);
                if(data.status == 1){
                    alert('修改成功!');
                }else{
                    alert('修改失败：'+data.msg);
                }
                
            })
        })
	</script>
</div><!-- /.main-content -->
